package org.streets.eis.ext.analysis.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.streets.database.datadict.ColumnDefinition;
import org.streets.eis.ext.analysis.components.ColumnWrapper;

@Entity
@Table(name="eis_query_order")
public class OrderField extends Field implements Serializable {
	
 	private static final long serialVersionUID = 1L;
 	@Column
	private String orderType = "ASC";
	
	public OrderField(){
		super();
	}
	
	public OrderField(String tableCode,String fieldCode,String fieldName){
		super( tableCode,fieldCode,fieldName);
	}
	
	public OrderField(ColumnDefinition col){
		super(col);
	}

	public OrderField(ColumnWrapper col){
		super(col);
	}
	
	public void setOrderType(String orderType) {
		if ((orderType.equalsIgnoreCase("ASC")) || (orderType.equalsIgnoreCase("DESC"))){
			this.orderType = orderType;
		}else{
			throw new RuntimeException(String.format("order by type[%s] is not valid !",orderType));
		}
	}
	public String getOrderType() {
		return orderType;
	}
}
